<p>
  In order to value the derivatives like options, the most significant part is to find a model to represent the underlying stock price so that we can price the options based on the underlying price.  We usually use the stochastic process to model the security price.
</p>
<p>
  First, you need to know what the stochastic process is. We say any variable that changes over time in an uncertain way follows a stochastic process. The price of a certain stock at a future time t is unknown at the present so it is a random variable \(S_t\). Then we can think of the movement path of the stock price is a stochastic process since\(S_t\) is a random variable at each time t in the future.
</p>
<p>
  Markov process is a special case of the stochastic process. It means that only the current value of a random variable is relevant for future prediction. In general, we usually assume that the stock price follows a Markov stochastic process, which means only the current stock price is relevant for predicting the future price, it is not correlated with the past price.
</p>
<p>
  Brownian motion is a particular type of Markov stochastic process or we can think of it as a family of random variables \(\left\{W_t\mid t\geq0\right\}\) indexed by time t. The one-dimensional Brownian motion is called the Wiener Process. (Brownian motion is n-dimensional Wiener processes which mean each dimension is just a standard Wiener process). It has the following properties:
</p>
<ul>
     <li>\(W_0=0\)</li>
     <li>For \(t\geq0\) and \(\Delta t\geq0\), the increment \(W_{t+\Delta t}-W_t\) is normally distributed with mean 0 and standard deviation \(\sqrt{\Delta t}\) .</li>
     <li>For any partitions \(0\leq t_1&lt;t_2&lt;\cdot\cdot\cdot &lt;t_n\), the increments \(W_{t_1}- W_{t_0},W_{t_2}-W_{t_1},\cdot\cdot\cdot, W_{t_n}-W_{t_{n-1}}\) are independent random variables.</li>
     <li>With probability 1, the function W(t) is continuous at t.</li>
</ul>
<p>
  Intuitively understanding of the definition, Wiener process has independent and normally distributed increments and has continuous sample path.
</p>
<p>
  Next, we simulate the Wiener process and plot the paths attempting to gain an intuitive understanding of a stochastic process. Each path is an independent Wiener process.
</p>
<div class="section-example-container">

<pre class="python">
import numpy as np
import matplotlib.pyplot as plt
%pylab inline
def wiener_process(T, N):
    """
    T: total time
    N: The total number of steps
    """
    W0 = [0]
    dt = T/float(N)
    # simulate the increments by normal random variable generator
    increments = np.random.normal(0, 1*np.sqrt(dt), N)
    W = W0 + list(np.cumsum(increments))
    return W

N = 1000
T = 10
dt = T / float(N)
t = np.linspace(0.0, N*dt, N+1)
plt.figure(figsize=(15,10))
for i in range(5):
    W = wiener_process(T, N)
    plt.plot(t, W)
    plt.xlabel('time')
    plt.ylabel('W')
    plt.grid(True)
</pre>
</div>

<img class="img-responsive" src="https://cdn.quantconnect.com/tutorials/i/Tutorial03-wiener-process.png" alt="wiener process"/>

<p>
  In ordinary calculus,\(\text{d}x=a\ \text{d}t\) is used to indicate that\(\Delta x=a\Delta t\) as \( \Delta t\rightarrow0\). We use the similar notation here. The mean change per unit time for a stochastic process is known as the drift rate and the variance per unit time is known as the variance rate. We can write the derivative of Wiener process over time t in this form: \(dW_t\).A standard Wiener process has a drift rate (i.e. average change per unit time) of 0 and a variance rate of 1 per unit time. If we extend the concept of Wiener process to a generalized Wiener process in the form: \(\text d\ x_t=a\ \text d t+b\ \text dW_t\). The drift rate and the variance rate can be set equal to any chosen constant. If we write it as approximate discrete form as
</p>
\[\Delta x=x_{t+\Delta t}-x_t=a\Delta t+b\epsilon\sqrt{\Delta t}\]
<p>
  Where ε follows the standard normal distribution N(0,1). Thus \(\Delta x\) has normal distribution with the mean being \(a\Delta t\), variance being \(b^2\Delta t\). And because \(\Delta t\) is independent, from time 0 to time T, the change in the value of x is just the sum of \(\Delta x\) in each small time interval. It means that the change in the value of x follows the normal distribution \(N(aT,b^2T)\).
</p>
